package cn.wsalix.msg.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.CommonEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @author jskyme 聊天消息
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "CHAT")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(exclude = {}, callSuper = false)
@ToString(exclude = {})
public class Chat extends CommonEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3947000995163652460L;
	private String content;
	private Long senderId;
	private String senderName;
	private Long receiveId;
	private String receiveName;
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_CHAT_ISSUE"), name = "ISSUE_ID")
	private Issue issue;

	@Temporal(TemporalType.TIMESTAMP)
	private Date sendTime;
	/*
	 * @JsonIgnore
	 * 
	 * @ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch =
	 * FetchType.LAZY)
	 * 
	 * @JoinColumn(name = "SENDER_ID") private SysUser sender;// 接收者
	 * 
	 * @JsonIgnore
	 * 
	 * @ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch =
	 * FetchType.LAZY)
	 * 
	 * @JoinColumn(name = "SENDEE_ID") private SysUser sendee;// 接收者 private
	 * boolean readed;
	 */
}